package com.css.zfzx.sjcj.modules.hddcStrongSeismicCatalog.service.impl;

import cn.afterturn.easypoi.excel.entity.result.ExcelVerifyHandlerResult;
import cn.afterturn.easypoi.handler.inter.IExcelVerifyHandler;
import com.css.bpm.platform.utils.PlatformObjectUtils;
import com.css.zfzx.sjcj.common.excel.util.ActiveFaultEasyExcelVerifyHelper;
import com.css.zfzx.sjcj.modules.hddcStrongSeismicCatalog.viewobjects.HddcStrongseismiccatalogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>1970年前4 3_4以上强震目录-点 导入校验</p>
 * 
 * @author liuhy
 * @date 2021/8/24
 */
@Component
public class StrongseismicCatelogsBefor1970_4_3_4ExcelVerifyHandler implements IExcelVerifyHandler<HddcStrongseismiccatalogVO> {

    private final ActiveFaultEasyExcelVerifyHelper verifyHelper;

    @Autowired
    public StrongseismicCatelogsBefor1970_4_3_4ExcelVerifyHandler(ActiveFaultEasyExcelVerifyHelper verifyHelper) {
        this.verifyHelper = verifyHelper;
    }

    @Override
    public ExcelVerifyHandlerResult verifyHandler(HddcStrongseismiccatalogVO vo) {
        ExcelVerifyHandlerResult result = verifyHelper.verify(vo);
        if (PlatformObjectUtils.isEmpty(vo.getOccurrencedate())) {
            result.setMsg("日期不能为空");
            result.setSuccess(false);
            return result;
        } else if (PlatformObjectUtils.isEmpty(vo.getMagnitude())) {
            result.setMsg("震级 [M]不能为空");
            result.setSuccess(false);
            return result;
        } else if (PlatformObjectUtils.isEmpty(vo.getLat())) {
            result.setMsg("纬度不能为空");
            result.setSuccess(false);
            return result;
        } else if (PlatformObjectUtils.isEmpty(vo.getLon())) {
            result.setMsg("经度不能为空");
            result.setSuccess(false);
            return result;
        }
        return result;
    }
}
